﻿Imports System.Web
<Serializable()> _
Public Class FileTree
    Shared Sub New()
        LoadSubfolders()
    End Sub
    Public Shared Sub LoadSubfolders()
        _SubFolders = New List(Of ServerFolder)
        _SubFolders.Add(New ServerFolder(PathName, BasePathName.Replace("\", ""), 0))
    End Sub
    Private Shared _BasePathName As String
    Friend Shared Property BasePathName() As String
        Get
            If _BasePathName = Nothing Then
                _BasePathName = Configuration.WebConfigurationManager.AppSettings("BasePathDomains")
            End If
            If String.IsNullOrEmpty(_BasePathName) Then
                _BasePathName = "\"
            End If
            Return _BasePathName
        End Get
        Set(ByVal value As String)
            _BasePathName = value
        End Set
    End Property

    Private Shared _PathName As String
    Friend Shared Property PathName() As String
        Get
            If _PathName = Nothing Then
                _PathName = HttpContext.Current.Server.MapPath("~/" & BasePathName.Replace("\", "/")).Replace(BasePathName, "")
            End If
            If _PathName = Nothing Then
                _PathName = "c:/"
            End If
            Return _PathName
        End Get
        Set(ByVal value As String)
            _PathName = value
        End Set
    End Property
    Public Shared ReadOnly Property PublicPathName() As String
        Get
            Return PathName
        End Get
    End Property

    Private Shared _SubFolders As List(Of ServerFolder)
    Public Shared Property SubFolders() As List(Of ServerFolder)
        Get
            Return _SubFolders
        End Get
        Set(ByVal value As List(Of ServerFolder))
            _SubFolders = value
        End Set
    End Property
End Class